/****************************************************
 * @class BomReportGridPanel
 * @extends Ext.Window
 ***************************************************/
	BomReportGridPanel = Ext.extend(Ext.grid.GridPanel,{
		condition: null,
		store: null,
		cm: null,
		constructor: function(config){
			Ext.apply(this,config);
			
			this.condition = {};
			this.condition.limit = 100;
			
			this.store = new Ext.data.Store({
			    baseParams: this.condition,   
				proxy: new Ext.data.HttpProxy({
					method: 'POST',
					url: '/pdm/report/bomReport.htm'
				}),
				reader: new Ext.data.JsonReader({
					totalProperty: 'totalProperty',
					root: 'root',
					id: 'trackingNumber'
				},[
					{name: 'material_FK'},
					{name: 'prodVersion_FK'},
					{name: 'fab'},
					{name: 'orderTask'},
					{name: 'bomMemo'},
					{name: 'trackingNumber'}
				])
			});
			
			this.cm = new Ext.grid.ColumnModel([
		        {
		           header: "成品料号",
		           dataIndex: 'material_FK',
		           sortable: true,
		           width: 100
		        },{
		           header: "版本",
		           dataIndex: 'prodVersion_FK',
		           width: 50
		        },{
		           header: "适用厂别",
		           dataIndex: 'fab',
		           width: 50
		        },{
		           header: "表单状态",
		           dataIndex: 'orderTask',
		           width: 80
		        },{
		           header: "申请原因",
		           dataIndex: 'bomMemo',
		           width: 150
		        },{
		           header: "BOM单号",
		           dataIndex: 'trackingNumber',
		           sortable: true,
		           width: 80,
		           renderer: renderHref
		        }]);
		        	        
			BomReportGridPanel.superclass.constructor.call(this, {
				enableColumnMove: false,
				enableHdMenu: false,
				//enableColumnHide: false,
			    loadMask: {msg:"信息载入中..."},
			    viewConfig: {forceFit: true},
				region: 'center',
				border: true,
				autoHeight: true,
				layout: 'fit',
				split: true,
				stripeRows: true,
				ds: this.store,
				sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
				cm: this.cm,
				trackMouseOver: false,
				bbar: new Ext.PagingToolbar({
					pageSize: 100,
					store: this.store,
					displayInfo: true
				})
			});
		},
		load: function(c){
			this.condition.trackingNumber = c;
			this.store.load();
		}
	});
		
	function renderHref(v){
		v = "<a href=\"javascript:openBR('"+v+"')\" >"+v+"</a>";
		return v;
	}
	
	function openBR(v){
		jsonrpc = new JSONRpcClient("/pdm/JSON-RPC");
		try{
			var info = jsonrpc.jabsorbService.getDispatchUrl(v, Ext.fly("login_user").dom.value,"PP.BR");
		}catch(e){
			alert(e);
		}
		
		window.open("http://myivo.ivo.com.cn/Arcadia/servlet/WebDispatcher?mailCode="+info);
	}

/****************************************************
 * @class SelectedMaterialGrid
 * @extends Ext.Window
 ***************************************************/
	SelectedMaterialGrid = Ext.extend(Ext.grid.GridPanel,{
		condition: null,
		store: null,
		cm: null,
		btn_auth: null,
		win_MaterialProduVer: null,
		hidden_BoMParam: null,
		constructor: function(config){
			Ext.apply(this,config);
			
			this.condition = {};
			this.condition.limit = 200;
			
			this.store = new Ext.data.Store({
			    baseParams: this.condition,   
				proxy: new Ext.data.HttpProxy({
					method: 'POST',
					url: '/pdm/report/bomReport.htm'
				}),
				reader: new Ext.data.JsonReader({
					totalProperty: 'totalProperty',
					root: 'root',
					id: 'trackingNumber'
				},[
					{name: 'material_FK'},
					{name: 'prodVersion_FK'},
					{name: 'fab'},
					{name: 'orderTask'},
					{name: 'bomMemo'},
					{name: 'trackingNumber'}
				])
			});
			
			this.cm = new Ext.grid.ColumnModel([
		        {
		           header: "成品料号",
		           dataIndex: 'material_FK',
		           sortable: true,
		           width: 80
		        },{
		           header: "版本",
		           dataIndex: 'prodVersion_FK',
		           width: 50
		        },{
		           header: "适用厂别",
		           dataIndex: 'fab',
		           width: 50
		        }]);
	        
			SelectedMaterialGrid.superclass.constructor.call(this, {
				enableColumnMove: false,
				enableHdMenu: false,
			    loadMask: {msg: "信息载入中..."},
			    viewConfig: {forceFit: true},
				region: 'center',
				border: true,
				autoHeight: true,
				layout: 'fit',
				split: true,
				stripeRows: true,
				ds: this.store,
				sm: new Ext.grid.RowSelectionModel({singleSelect: true}),
				cm: this.cm,
				trackMouseOver: false,
				tbar: ['->',{
					text: "添加",
					scope: this,
					iconCls: 'add',
					tooltip: "选择条件",
					hidden: (this.btn_auth=="false"),
					handler: function(){
						
					}
				},'-',{
					text: "删除",
					scope: this,
					iconCls: 'delete',
					hidden: (this.btn_auth=="false"),
					handler: function(){
						
					}
				}]
			});
		},
		load: function(c){
			this.condition.trackingNumber = c;
			this.store.load();
		}
	});
